package com.potato.rxjavademo.observer_model

class WeChatServerObservable :Observable {

    private var observers:MutableList<Observer> = ArrayList()
    private var message:Any?=null;

    override fun addObserver(observer: Observer) {
        observers.add(observer!!)
    }

    override fun removeObserver(observer: Observer) {
        observers.remove(observer)
    }

    override fun nofityObservers() {
        observers.forEach {
            it.update(message!!)
        }
    }

    override fun pushObservers(message: Any) {
        this.message= message
        nofityObservers()
    }
}